home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 14053 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.5 KB  |  60 lines

  1. Path: informatik.uni-bremen.de!news
  2. From: thuerman@informatik.uni-bremen.de (Urs Thuermann)
  3. Newsgroups: comp.lang.c++
  4. Subject: overloading and ellipsis
  5. Date: 28 Mar 1996 17:49:57 +0100
  6. Organization: Universitaet Bremen, Germany.
  7. Message-ID: <tuka05p3gq.fsf@twit.informatik.uni-bremen.de>
  8. NNTP-Posting-Host: twit.informatik.uni-bremen.de
  9. Mime-Version: 1.0
  10. Content-Type: text/plain; charset=iso-8859-1
  11. Content-Transfer-Encoding: 8bit
  12. Follow-Up: comp.lang.c++,poster
  13. X-Newsreader: Gnus v5.0.10
  14.  
  15. I'd like to overload a function with ellipsis but g++ doesn't let me
  16. do that.  Should that be possible?
  17.  
  18. void send(char *fmt, ...)
  19. {
  20.     ;
  21. }
  22.  
  23. void send(char *fmt, va_list)
  24. {
  25.     ;
  26. }
  27.  
  28. void send(char *s)
  29. {
  30.     ;
  31. }
  32.  
  33. main()
  34. {
  35.     va_list ap;
  36.  
  37.     send("abc %d\n", 13); // ok, calls first function
  38.  
  39.     send("abc %d\n", ap); // ok, calls second function
  40.  
  41.     send("abc\n");  // error:  ambiguous
  42. }
  43.  
  44. The second call is ok, because the argument ap does match better to
  45. va_list than to "...", according to ARM r.13.2
  46.  
  47.     [5] Match with ellipsis: Sequences that involve matches with
  48.         ellipsis are worse than all others.
  49.  
  50. This, of course sequences of conversion, so it doesn't apply to the
  51. third call in my example where no conversion is neccessary.
  52. But nevertheless I would think that the third function matches better
  53. than the first for the third call in main(), so there would be exactly
  54. one best match and the call legal.
  55. Does the ARM say something about this, and is g++ correct?
  56.  
  57. Please also answer me by email.
  58.  
  59. urs
  60.